package com.taotao.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.pojo.Item;
import com.taotao.service.ItemService;

/**
 * 商品管理
 * @author 恒安
 *
 */
@Controller
@RequestMapping("/item")
public class ItemController {
	private static Logger logger = LoggerFactory.getLogger(ItemController.class);
	
	@Autowired
	private ItemService itemService;
	
	@RequestMapping("/getItemById")
	@ResponseBody
	public Item getItemById(Long itemId){
		logger.info("获取商品详情----" + itemId);
		Item item = null;
		try{
			item = itemService.selectByPrimaryKey(itemId);
		}catch(Exception e){
			e.printStackTrace();
		}
		return item;
	}
	
	@RequestMapping("/item-list")
	public String itemList(){
		return "/item/item-list";
	}
	
	@RequestMapping("/getItemList")
	@ResponseBody
	public EUDataGridResult getItemList(Integer page,Integer rows,Model model){
		//查询商品列表
		EUDataGridResult result = itemService.getItemList(page,rows);
		return result;
	}
	
	@RequestMapping("/item-add")
	public String itemAdd(){
		return "/item/item-add";
	}
	
	@RequestMapping("/item-edit")
	public String itemEdit(){
		return "/item/item-edit";
	}
	
}
